<?php
/**
 * http://yiibook.com/book/en/yii1.1_application_development_cookbook/chapter-9
 * 
 * @author Administrator
 *
 */
class LogController extends CController {
	
	protected function beforeAction($action)
	{
		// 关闭日志
		foreach ( Yii::app ()->log->routes as $route ) {
			if ($route instanceof CWebLogRoute || $route instanceof CFileLogRoute || $route instanceof YiiDebugToolbarRoute)
			{
				$route->enabled = false;
			}
		}
		return true;
	}
	
	public function actionIndex() {
		Yii::trace ( 'example trace message', 'example' );
		Yii::log ( 'info', CLogger::LEVEL_INFO, 'example' );
		Yii::log ( 'error', CLogger::LEVEL_ERROR, 'example' );
		Yii::log ( 'trace', CLogger::LEVEL_TRACE, 'example' );
		Yii::log ( 'warning', CLogger::LEVEL_WARNING, 'example' );
		Yii::beginProfile ( 'preg_replace', 'example' );
		for($i = 0; $i < 10000; $i ++) {
			preg_replace ( '~^[ a-z]+~', '', 'test it' );
		}
		Yii::endProfile ( 'preg_replace', 'example' );
		
		echo 'done';
	}
	public function a() {
		// 关闭日志
		foreach ( Yii::app ()->log->routes as $route ) {			
			if ($route instanceof CWebLogRoute || $route instanceof CFileLogRoute || $route instanceof YiiDebugToolbarRoute) 
			{				
				$route->enabled = false;
			}
		}
	}
}